package com.bjsxt.service.impl;

import com.bjsxt.mapper.HostMapper;
import com.bjsxt.pojo.Host;
import com.bjsxt.pojo.PageA;
import com.bjsxt.service.HostService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HostServiceimpl implements HostService {
    @Autowired
    private HostMapper hostMapper;
    @Override
    public PageA<Host> findMore(Integer page, Integer rows,Host host) {
        Page pg = PageHelper.startPage(page, rows);
        List<Host> list = hostMapper.selectMore(host);
        PageA<Host> pga = new PageA<>(list, pg.getTotal());
        return pga;
    }
//添加主持人信息
    @Override
    public Integer save(Host host) {
        return hostMapper.insert(host);
    }
//修改权重
    @Override
    public Integer updateStrong(Integer strong, Integer hid) {
        return hostMapper.updateStrong(strong, hid);
    }
//修改状态
    @Override
    public Integer updateStatus(Integer[] hids, String status) {
        int a =0;
        try {
            for (Integer hid: hids){
                hostMapper.updateStatus(hid, status);
            }
               a=1;
        } catch (Exception e) {
           throw e;
        }
        return a;
    }


}
